package com.guoxin.chapter4.reentractlock.useconditionwaitnotifyerror;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class MyService {
	private Lock lock = new ReentrantLock();
	private Condition condition = lock.newCondition();
	
	/**
	 * 该方法会抛出java.lang.IllegalMonitorStateException异常
	 * 监视器出错，必须在condition.await()方法调用之前用lock.lock()代码获得同步监视器
	 */
	public void await(){
		try {
			condition.await();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
